/* *  
 * Copyright (C) 2004-2008 Mocha Almond Fudge AI, SIT KMUTT
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 */
package jboard.ui;

import java.awt.Color;
import java.awt.Component;
import java.awt.Graphics;

import javax.swing.Icon;

import jboard.model.IBoardConstant;

/**
 * This class responsible for draw pawn on the Board GUI,<br>
 * and also cross line.
 * 
 * @author Vashira Ravipanich
 */
public class BoardCell implements Icon, IBoardConstant {
	private int CellType;
	
	public BoardCell(int type) {
	    this.CellType = type;
	}

    public int getIconHeight() {
        return CELL_SIZE;
    }

    public int getIconWidth() {
        return CELL_SIZE;
    }

    public void paintIcon(Component comp, Graphics g, int x_origin, int y_origin) {

        if (CellType == BLACK) {
            g.setColor(Color.black);
        } else if (CellType == WHITE) {
            g.setColor(Color.white);
        } else if (CellType == SELECT) {
            g.setColor(Color.white);
        } else if (CellType == MOVEABLE) {
            g.setColor(Color.yellow); // split from select type
        }

        if (CellType == BLACK || CellType == WHITE) {
            g.fillArc(x_origin + CELL_SIZE / 5, y_origin + CELL_SIZE / 5,
                    (CELL_SIZE * 3) / 5, (CELL_SIZE * 3) / 5, 0, 360);
            if (CellType == BLACK) { // just decoration
                g.setColor(Color.gray);
                g.drawArc(x_origin + CELL_SIZE / 5, y_origin + CELL_SIZE / 5,
                        (CELL_SIZE * 3) / 5, (CELL_SIZE * 3) / 5, 0, 360);
            }
        } else { // select and moveable cell
            g.drawRect(x_origin, y_origin, x_origin + 49, y_origin + 49);
        }
    }
    
}